package com.bwie.es;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.bwie.poi.Excel;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.io.Serializable;
import java.util.Date;

/**
 * @author 军哥
 * @version 1.0
 * @description: 用户的es实体类
 * @date 2024/10/24 13:23
 */

@Data
@Document(indexName = "es_user", shards = 1, replicas = 0)
// indexName 索引的名字不要使用大写字母
// shards 分片数量
// replicas 副本数量
public class EsUser implements Serializable {
    @Id
    @Field(type = FieldType.Keyword)
    private Integer userId;

    // Text 表示需要分词，必须指定分词器
    @Field(type = FieldType.Keyword)
    private String userName;

    // Keyword 表示不分词 index 表示仅存储，不检索
    @Field(type = FieldType.Keyword, index = false)
    private String userPass;

    @Field(type = FieldType.Keyword)
    private String userMobile;

    @Field(type = FieldType.Text, analyzer = "ik_max_word")
    private String userMail;

    @Field(type = FieldType.Text, analyzer = "ik_max_word")
    private String nickName;

    @Field(type = FieldType.Integer)
    private Integer userRole;

    @Field(type = FieldType.Text, analyzer = "ik_max_word")
    private String idCode;

    @Field(type = FieldType.Integer)
    private Integer userCheck;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8", shape = JsonFormat.Shape.STRING)
    @Field(type = FieldType.Date, format = DateFormat.custom, pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;
}
